<template>
	<div>
		<div class="toplogo">
			<div class="logo">
				<img class="logoimage" @click="emitlogo" :src="formdata.logo" alt="" />
			</div>
		</div>
	</div>
</template>

<script setup>
	import {loginmodel,homemodel} from '@/api/services/api'
	import {
		ElMessage,
		ElLoading,
		ElNotification
	} from 'element-plus'
	import { onMounted,ref,defineProps, toRefs,defineEmits} from 'vue';
	let LoadingInstance = null;
	const formdata = reactive({
		logo:''
	})
	// 父传子 （父组件和2一样）
	// const props = defineProps({
	// 	indexs:''
	// })
	// const {indexs} = toRefs(props)
	// 子传父
	const emit = defineEmits(['logomsg']);
	const userconfigfun = () => {
		LoadingInstance = ElLoading.service({
			lock: true,
			text: 'Loading',
			background: 'rgba(0, 0, 0, 0.7)'
		});
		homemodel.userconfigapi().then((res) => {
			LoadingInstance.close()
			if (res.code == 1) {
				formdata.logo = res.data.website.shop_logo;
				emit('logomsg',formdata.logo)
			} else {
				ElNotification({
					message: res.msg,
					showClose: false,
					icon: 'Platform',
					customClass: 'notion_customClass',
					duration: 1000
				})
			}
		}).catch((err) => {
			LoadingInstance.close()
		})
	};
	onMounted(()=>{
		userconfigfun();
	});
</script>

<style scoped lang="less">
	.toplogo {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 40px;
		padding: 9px 0;
		background-color: #2F75FF;
		z-index: 999;
		.logo {
			width: 90%;
			margin: auto;
			height: 22px;
	
			.logoimage {
				height: 22px;
				border-radius:5px;
			}
		}
	}
</style>